from django.db import models

# Create your models here.


class User(models.Model):
    name = models.CharField(verbose_name="用户名", max_length=20, null=True, blank=True)
    email = models.EmailField(verbose_name="邮箱", null=True, blank=True)
    password = models.CharField(verbose_name="密码", max_length=32, null=True, blank=True)
    job_choices = (
        (1, "普通用户"),
        (2, "管理员"),
    )
    job = models.SmallIntegerField(verbose_name="职位", choices=job_choices, default=1)


class User_TieZi_Like(models.Model):
    user_id = models.ForeignKey(verbose_name="点赞用户id", to="User", to_field="id", on_delete=models.CASCADE)
    like_id = models.ForeignKey(verbose_name="被点赞文本id", to="TieZi", to_field="id", on_delete=models.CASCADE)
    like_time = models.DateTimeField(verbose_name="点赞时间", null=True, blank=True)


class User_Article_Like(models.Model):
    user_id = models.ForeignKey(verbose_name="点赞用户id", to="User", to_field="id", on_delete=models.CASCADE)
    like_id = models.ForeignKey(verbose_name="被点赞文本id", to="Article", to_field="id", on_delete=models.CASCADE)
    like_time = models.DateTimeField(verbose_name="点赞时间", null=True, blank=True)


class UserGameScore(models.Model):
    user_id = models.ForeignKey(verbose_name="用户id", to="User", to_field="id", on_delete=models.CASCADE)
    game_id = models.ForeignKey(verbose_name="被点赞文本id", to="Game", to_field="id", on_delete=models.CASCADE)
    score = models.IntegerField(verbose_name="评分")
    time = models.DateTimeField(verbose_name="点赞时间", null=True, blank=True)


class UserNovelScore(models.Model):
    user_id = models.ForeignKey(verbose_name="点赞用户id", to="User", to_field="id", on_delete=models.CASCADE)
    game_id = models.ForeignKey(verbose_name="被点赞文本id", to="Novel", to_field="id", on_delete=models.CASCADE)
    score = models.IntegerField(verbose_name="评分")
    time = models.DateTimeField(verbose_name="点赞时间", null=True, blank=True)


class BanKuai(models.Model):
    name = models.CharField(verbose_name="板块名", max_length=62)
    user_id = models.ForeignKey(verbose_name="版主", to="User", to_field="id", on_delete=models.CASCADE)
    father_id = models.ForeignKey(verbose_name="父版块", to="BanKuai", to_field="id", on_delete=models.CASCADE, null=True, blank=True)
    describe = models.TextField(verbose_name="板块描述", max_length=300)


class TieZi(models.Model):
    bankuai_id = models.ForeignKey(verbose_name="板块id", to="BanKuai", to_field="id", on_delete=models.CASCADE, )
    user_id = models.ForeignKey(verbose_name="发布者id", to="User", to_field="id", on_delete=models.CASCADE)
    title = models.CharField(verbose_name="标题", max_length=100)
    content = models.TextField(verbose_name="内容")
    release_time = models.DateTimeField(verbose_name="发布时间")
    likes = models.IntegerField(verbose_name='点赞数', default=0)
    view_count = models.PositiveIntegerField(verbose_name="浏览量", default=0)
    reply_count = models.PositiveIntegerField(verbose_name="回复数", default=0)
    is_top = models.BooleanField(verbose_name="置顶", default=False)
    status = models.BooleanField(verbose_name="精华", default=False)


class Article(models.Model):
    user_id = models.ForeignKey(verbose_name="发布者id", to="User", to_field="id", on_delete=models.CASCADE)
    title = models.CharField(verbose_name="标题", max_length=100, null=True, blank=True)
    abstract = models.TextField(verbose_name="摘要", null=True, blank=True)
    content = models.TextField(verbose_name="内容", null=True, blank=True)
    release_time = models.DateTimeField(verbose_name="发布时间")
    likes = models.IntegerField(verbose_name='点赞数', default=0)
    comments = models.IntegerField(verbose_name='评论数', default=0)
    view_count = models.PositiveIntegerField(verbose_name="浏览量", default=0)
    is_top = models.BooleanField(verbose_name="置顶", default=False)
    status = models.BooleanField(verbose_name="精华", default=False)


class Novel(models.Model):
    bankuai_id = models.ForeignKey(verbose_name="板块id", to="BanKuai", to_field="id", on_delete=models.CASCADE)
    author = models.CharField(verbose_name="作者（出版社）id", max_length=100)
    user_id = models.ForeignKey(verbose_name="发布者id", to="User", to_field="id", on_delete=models.CASCADE)
    title = models.CharField(verbose_name="标题", max_length=100)
    abstract = models.TextField(verbose_name="摘要")
    content = models.TextField(verbose_name="内容")
    release_time = models.DateTimeField(verbose_name="发布时间")
    likes = models.IntegerField(verbose_name='点赞数', default=0)
    comments = models.IntegerField(verbose_name='评论数', default=0)
    score = models.IntegerField(verbose_name="评分", default=0)


class Game(models.Model):
    bankuai_id = models.ForeignKey(verbose_name="板块id", to="BanKuai", to_field="id", on_delete=models.CASCADE)
    name = models.CharField(verbose_name="名称", max_length=100)
    author = models.CharField(verbose_name="作者（出版社）", max_length=100)
    abstract = models.TextField(verbose_name="简介")
    release_time = models.DateTimeField(verbose_name="发行时间")
    likes = models.IntegerField(verbose_name='点赞数', default=0)
    comments = models.IntegerField(verbose_name='评论数', default=0)
    score = models.IntegerField(verbose_name="评分", default=0)


class Merch(models.Model):
    id = models.AutoField(verbose_name="周边ID", primary_key=True)  #
    bankuai_id = models.ForeignKey(verbose_name="板块id", to="BanKuai", to_field="id", on_delete=models.CASCADE)
    name = models.CharField(verbose_name="名称", max_length=100)
    price = models.DecimalField(verbose_name="价格", max_digits=10, decimal_places=2)
    author = models.CharField(verbose_name="生产厂", max_length=100)
    release_time = models.DateTimeField(verbose_name="发行时间")
    likes = models.IntegerField(verbose_name='点赞数', default=0)
    comments = models.IntegerField(verbose_name='评论数', default=0)


class ReplyArticle(models.Model):
    article_id = models.ForeignKey(verbose_name="回复帖id", to="Article", to_field="id", on_delete=models.CASCADE)
    user_id = models.ForeignKey(verbose_name="回复者id", to="User", to_field="id", on_delete=models.CASCADE)
    # 下面这一行是与本表的特征建立外键，我没有理解，可行的话删除注释
    replyarticle_id = models.IntegerField(verbose_name="回复的文章的id", null=True, blank=True)
    reply_reply_id = models.IntegerField(verbose_name="回复的回复的楼主的id", null=True, blank=True)
    content = models.TextField(verbose_name="内容")
    release_time = models.DateTimeField(verbose_name="发布时间")
    order = models.IntegerField(verbose_name="显示顺序", null=True, blank=True)
    likes = models.IntegerField(verbose_name='点赞数', default=0)


class ReplyTieZi(models.Model):
    tiezi_id = models.ForeignKey(verbose_name="回复帖id", to="TieZi", to_field="id", on_delete=models.CASCADE)
    user_id = models.ForeignKey(verbose_name="回复者id", to="User", to_field="id", on_delete=models.CASCADE)
    # 下面这一行是与本表的特征建立外键，我没有理解，可行的话删除注释
    replytiezi_id = models.IntegerField(verbose_name="回复的帖子的id", null=True, blank=True)
    reply_reply_id = models.IntegerField(verbose_name="回复的回复的楼主的id", null=True, blank=True)
    content = models.TextField(verbose_name="内容")
    release_time = models.DateTimeField(verbose_name="发布时间")
    order = models.IntegerField(verbose_name="显示顺序", null=True, blank=True)
    likes = models.IntegerField(verbose_name='点赞数', default=0)


class ReplyMerch(models.Model):
    merch_id = models.ForeignKey(verbose_name="回复周边id", to="Merch", to_field="id", on_delete=models.CASCADE)
    user_id = models.ForeignKey(verbose_name="回复者id", to="User", to_field="id", on_delete=models.CASCADE)
    # 同上
    replymerch_id = models.IntegerField(verbose_name="回复的周边的id", null=True, blank=True)
    content = models.TextField(verbose_name="内容")
    release_time = models.DateTimeField(verbose_name="发布时间")
    order = models.IntegerField(verbose_name="显示顺序")
    likes = models.IntegerField(verbose_name='点赞数', default=0)


class ReplyNovel(models.Model):
    novel_id = models.ForeignKey(verbose_name="评论小说的id", to="Novel", to_field="id", on_delete=models.CASCADE)
    user_id = models.ForeignKey(verbose_name="回复者id", to="User", to_field="id", on_delete=models.CASCADE)
    content = models.TextField(verbose_name="内容")
    release_time = models.DateTimeField(verbose_name="发布时间")
    order = models.IntegerField(verbose_name="显示顺序")
    score = models.IntegerField(verbose_name="评分", default=0)
    likes = models.IntegerField(verbose_name='点赞数', default=0)


class ReplyGame(models.Model):
    game_id = models.ForeignKey(verbose_name="评论游戏的id", to="Game", to_field="id", on_delete=models.CASCADE)
    user_id = models.ForeignKey(verbose_name="回复者id", to="User", to_field="id", on_delete=models.CASCADE)
    content = models.TextField(verbose_name="内容")
    release_time = models.DateTimeField(verbose_name="发布时间")
    order = models.IntegerField(verbose_name="显示顺序")
    score = models.IntegerField(verbose_name="评分", default=0)
    likes = models.IntegerField(verbose_name='点赞数', default=0)
